package com.qvtu.management.service.impl;

import com.qvtu.management.mapper.DeptMapper;
import com.qvtu.management.pojo.Dept;
import com.qvtu.management.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;


    @Override
    //查询所有部门信息
    public List<Dept> list(){
        return deptMapper.list();
    }
    @Override
    public void delete(Integer id) {
        deptMapper.deleteById(id);
    }

    //新增部门
    @Override
    public void add(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.insert(dept);

    }
    //根据id查询部门
    @Override
    public Dept selectById(Integer id) {
        return deptMapper.selectById(id);
    }


    //修改部门
    @Override
    public void update(Dept dept) {
        deptMapper.updateById(dept);
    }

}
